import { AdManager } from "../ads/AdManager";
import { EventManager } from "../manager/EventManager";
import { UIManager } from "../manager/UIManager";
import { BUNDLE_TYPE_ENUM, EVENT_NAME_ENUM } from "../base/EnumIndex";
import { AudioManager1 } from "../manager/AudioManager1";
import { LevelManager } from "../manager/LevelManager";

const { ccclass, property } = cc._decorator;

@ccclass
export default class TimeUI extends cc.Component {
    onLoad() {
    }
    start() {
        AdManager.naoLiReportVideo(1, "加时");
    }

    /** 返回主页 */
    returnMain() {
        // UIManager.ins.showPop("OverUI", BUNDLE_TYPE_ENUM.GAME);
        UIManager.ins.showUI("LevelUI", BUNDLE_TYPE_ENUM.HOME)
    }

    clickBtnReturn() {
        AudioManager1.playClick();
        UIManager.ins.closeAll();
        //继续
        let lvName = LevelManager.ins.getBundleName();
        if (lvName == "15_268") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_268")
            level15.resumeAni();
        }
        if (lvName == "15_271") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_271")
            level15.resumeAni();
        }
        if (lvName == "15_272") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_272")
            level15.resumeAni();
        }
        if (lvName == "15_279") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_279")
            level15.resumeAni();
        }
        if (lvName == "15_281") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_281")
            level15.resumeAni();
        }
        if (lvName == "15_287") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_287")
            level15.resumeAni();
        }
        if (lvName == "15_286") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_286")
            level15.resumeAni();
        }
        if (lvName == "15_288") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_288")
            level15.resumeAni();
        }
        if (lvName == "15_289") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_289")
            level15.resumeAni();
        }
        if (lvName == "15_299") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_299")
            level15.resumeAni();
        }
        if (lvName == "15_301") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_301")
            level15.resumeAni();
        }
        if (lvName == "15_302") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_302")
            level15.resumeAni();
        }
        if (lvName == "15_304") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_304")
            level15.resumeAni();
        }
        if (lvName == "15_305") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_305")
            level15.resumeAni();
        }
        if (lvName == "15_308") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_308")
            level15.resumeAni();
        }
        if (lvName == "15_307") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_307")
            level15.resumeAni();
        }
        if (lvName == "15_290") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_290")
            level15.resumeAni();
        }
        if (lvName == "15_309") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_309")
            level15.resumeAni();
        }
        if (lvName == "15_317") {
            let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_317")
            level15.resumeAni();
        }
        // this.returnMain();
        LevelManager.ins.loadLevelPre();
    }

    clickBtnAddTime() {
        AudioManager1.playClick();
        let idx = LevelManager.ins.getLvInfoIdx(LevelManager.ins.curLvInfo.type, LevelManager.ins.curLvInfo.lv) + 1;
        AdManager.reportVideo(4, idx, LevelManager.ins.curLvInfo.name);
        AdManager.naoLiReportVideo(2, "加时");
        AdManager.showVideoAd(() => {
            AdManager.reportOverVideo(idx, LevelManager.ins.curLvInfo.name);
            UIManager.ins.close();
            //继续
            let lvName = LevelManager.ins.getBundleName();
            if (lvName == "15_268") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_268")
                level15.resumeAni();
            }
            if (lvName == "15_271") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_271")
                level15.resumeAni();
            }
            if (lvName == "15_272") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_272")
                level15.resumeAni();
            }
            if (lvName == "15_279") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_279")
                level15.resumeAni();
            }
            if (lvName == "15_281") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_281")
                level15.resumeAni();
            }
            if (lvName == "15_287") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_287")
                level15.resumeAni();
            }
            if (lvName == "15_286") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_286")
                level15.resumeAni();
            }
            if (lvName == "15_288") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_288")
                level15.resumeAni();
            }
            if (lvName == "15_289") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_289")
                level15.resumeAni();
            }
            if (lvName == "15_299") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_299")
                level15.resumeAni();
            }
            if (lvName == "15_301") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_301")
                level15.resumeAni();
            }
            if (lvName == "15_302") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_302")
                level15.resumeAni();
            }
            if (lvName == "15_304") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_304")
                level15.resumeAni();
            }
            if (lvName == "15_305") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_305")
                level15.resumeAni();
            }
            if (lvName == "15_308") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_308")
                level15.resumeAni();
            }
            if (lvName == "15_307") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_307")
                level15.resumeAni();
            }
            if (lvName == "15_290") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_290")
                level15.resumeAni();
            }
            if (lvName == "15_309") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_309")
                level15.resumeAni();
            }
            if (lvName == "15_317") {
                let level15 = cc.director.getScene().getChildByName("Canvas").getComponentInChildren("Level_15_317")
                level15.resumeAni();
            }
            EventManager.ins.emit(EVENT_NAME_ENUM.ADD_TIME);
            AdManager.naoLiReportVideo(3, "加时");
            AdManager.naoLiReportVideo(4, "加时");
        });
    }
}
